cmake_minimum_required(VERSION 3.5)
project(agv_obstacle_avoidance)

set(CMAKE_CXX_STANDARD 17)
add_compile_options(-std=c++17)

if(POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_auto REQUIRED) 

set(THIS_PACKAGE_ROS_DEPS
    rclcpp
    std_msgs
    sensor_msgs
    geometry_msgs
    tf2_ros
    tf2_geometry_msgs
    message_filters
    laser_geometry
    pluginlib
    angles
    pcl_conversions
    pcl_ros
    agv_msgs
    agv_srvs
)

foreach(dep ${THIS_PACKAGE_ROS_DEPS})
    find_package(${dep} REQUIRED)
endforeach()

find_package(Boost REQUIRED COMPONENTS system)
find_package(PCL REQUIRED COMPONENTS common io filters)
# find_package(tinyxml2 REQUIRED)

include_directories(
    include
    ${Boost_INCLUDE_DIRS}
    ${PCL_INCLUDE_DIRS}
    ${tinyxml2_INCLUDE_DIRS}
)

add_executable(agv_obstacle_avoidance
    src/node_main.cpp
    src/laser_obsta_avoid.cpp
    src/scan_filter.cpp
    src/depth_camera.cpp
    src/scenes_judge.cpp
    src/io_obsta_avoid.cpp
)

target_link_libraries(agv_obstacle_avoidance
    ${rclcpp_LIBRARIES}
    ${std_msgs_LIBRARIES}
    ${sensor_msgs_LIBRARIES}
    ${geometry_msgs_LIBRARIES}
    ${tf2_ros_LIBRARIES}
    ${message_filters_LIBRARIES}
    ${laser_geometry_LIBRARIES}
    ${pluginlib_LIBRARIES}
    ${angles_LIBRARIES}
    ${pcl_conversions_LIBRARIES}
    ${pcl_ros_LIBRARIES}
    ${agv_msgs_LIBRARIES}
    ${agv_srvs_LIBRARIES}
    ${Boost_LIBRARIES}
    ${PCL_LIBRARIES}
    tinyxml2::tinyxml2
)

ament_target_dependencies(agv_obstacle_avoidance
  "std_msgs"
  "agv_msgs"
  "agv_srvs"
  "geometry_msgs"
  "tf2_geometry_msgs"
  "pcl_conversions"
  "angles"
  "rclcpp"
)


install(TARGETS agv_obstacle_avoidance
    DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY launch/
    DESTINATION share/${PROJECT_NAME}/launch
)

ament_package()